home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / biz / swood / FWTabTools.lha / FWTabTools / FWCalcAddZeile.rexx < prev    next >
OS/2 REXX Batch file  |  1998-01-04  |  3KB  |  160 lines

  1. /* $VER: 0.15 , (04.01.1998), © by Thorsten Willert
  2.    
  3.    Macro um Tabellenzeilen zu addieren (den Inhalt
  4.    in Zahlen natürlich)
  5. ------------------------------------------------*/
  6.  
  7. ADDRESS = 'FinaW'
  8. OPTIONS CACHE RESULTS
  9.  
  10. STATUS PORTNAME
  11. FW = RESULT
  12. ADDRESS = FW
  13.  
  14. SIGNAL ON BREAK_C
  15. SIGNAL ON HALT
  16. SIGNAL ON SYNTAX
  17.  
  18. /*-----------------------------------------------*/
  19.  
  20. RT.Version   = "Version 0.15"
  21. RT.Title     = "FWAddZeile"
  22. RT.Para1     = "rt_pubscrname = FinalWriterPubScreen rt_topoffset = 50 rt_reqpos = reqpos_topleftwin"
  23. RT.Copyright = "© 1998, by Thorsten Willert"
  24.  
  25. R = '0A'X
  26.  
  27. /*-----------------------------------------------*/
  28.  
  29. IF ~show('L',"rexxreqtools.library") THEN DO
  30.    IF ~addlib('rexxreqtools.library',0,-30,0) THEN DO
  31.       'ShowMessage 1 1 "Fehler ..." "Benötige RexxReqTools.library!" "" "Abbruch !!" "" ""'
  32.       EXIT 20
  33.    END
  34. END
  35.  
  36. DO FOREVER
  37.  
  38.     IF Info("_Berechnen|_Ende" ) == 0 THEN LEAVE
  39.  
  40.     ADDRESS(FW)
  41.     GETDocItemPrefs Decimal
  42.     Punkt = result
  43.     result = ""
  44.  
  45.     IF SetCursor() = 0 THEN ITERATE
  46.     
  47.     CALL Addieren
  48.     
  49.     TableSetActiveCell StartZeile StartSpalte
  50.     
  51. END
  52.  
  53. /*-----------------------------------------------*/
  54.  
  55. Ende:
  56. EXIT
  57.  
  58. /*-----------------------------------------------*/
  59.  
  60. SetCursor:
  61.  
  62. ADDRESS(FW)
  63. TableGetActiveCell
  64. PARSE VAR RESULT Zeile Spalte
  65.  
  66. StartZeile = Zeile
  67. StartSpalte = Spalte
  68.  
  69. IF Zeile = "" | Spalte = "" THEN /* Geht nicht über GetObjektType */
  70.     DO
  71.         CALL KeineTabelle
  72.         RETURN 0
  73.     END
  74.  
  75. TableGetColumns
  76. PARSE VAR RESULT Muell Spalten
  77.  
  78. IF Spalte=Spalten THEN Spalte=1
  79.  
  80. TableSetActiveCell Zeile Spalte
  81.  
  82. RETURN 1
  83.  
  84. /*-----------------------------------------------*/
  85.  
  86. Addieren:
  87.  
  88. ADDRESS (FW)
  89.  
  90. i=1;Summand=0;Summe=0
  91.  
  92. DO FOREVER
  93.     i=i+1
  94.     TableSetActiveCell Zeile Spalte
  95.         SelectAll
  96.         Extract
  97.         Summand  = COMPRESS(RESULT,'09'X'0A'X" ")
  98.         Summand2 = TRANSLATE( Summand ,".",",")
  99.         IF ~DATATYPE( Summand2, "NUMERIC") = 0 THEN
  100.             DO
  101.                 Justify Right
  102.                 Summand=Summand2
  103.                 IF Summand = "" THEN Summand = 0
  104.             END
  105.             ELSE Summand=0
  106.             
  107. Summe=Summe+Summand
  108.  
  109. IF Spalte=Spalten-1 THEN LEAVE
  110. Spalte=Spalte+1
  111.  
  112. END
  113.  
  114. TableSetActiveCell Zeile Spalten
  115.     SelectAll
  116.     Clear
  117.     Justify Right
  118.     Style Bold
  119.         IF Punkt~="Period" THEN Summe=TRANSLATE(Summe,",",".")
  120.     Type Summe
  121.     
  122. RETURN
  123.  
  124. /*-----------------------------------------------*/
  125.  
  126. KeineTabelle:
  127.  
  128. rtezrequest("Zuerst eine Tabelle auswählen"||R||,
  129.             "und Cursor positioniern!","Weiter",RT.Title)
  130.  
  131. RETURN
  132.  
  133. /*-----------------------------------------------*/
  134.  
  135. Info:
  136. PARSE ARG Taste1
  137.  
  138. res = rtezrequest(RT.Version||","||R||RT.Copyright||R||R||,
  139.             "Addiert Zeilen ab Cursorposition",Taste1,RT.Title,RT.Para1)
  140.             
  141. RETURN res
  142.  
  143. /*-----------------------------------------------*/
  144.  
  145. HALT:
  146. BREAK_C:
  147.  
  148. rtezrequest("Macro wurde abgebrochen ... ","Weiter",RT.Title)
  149.  
  150. EXIT 10
  151.  
  152. /*-----------------------------------------------*/
  153.  
  154. SYNTAX:
  155.  
  156. IF RC = 47 THEN
  157. rtezrequest("Fehler!","_Weiter|_Hilfe",RT.Title)
  158. IF rtresult == 0 THEN CALL Info( "_Aha" )
  159.  
  160. EXIT 10